<template>
    <view>
			<view class="record">
                    <view class="record-title van-hairline--bottom">
                        <view class="record-title-item one">活动名称</view>
                        <view class="record-title-item">累计购买数量</view>
                        <view class="record-title-item">奖励条件(数量)</view>
                        <view class="record-title-item">操作</view>
                    </view>
                    <view class="tabs">
                        <view class="tabs-buy-list">
                            <block v-for="(item, index) in myActivityList" :key="index">
                                <view class="tbl-item">
                                    <view class="item buy-type one">{{ item.name }}</view>
                                    <view class="item buy">{{aprice}}</view>
                                    <view class="item">{{ item.startC }}-{{item.endC}}</view>
                                    <view class="item color6" @tap="onReceiveAward(item)">{{aprice >= item.startC && item.endC >= aprice ? '领取' : ''}}</view>
                                </view>
                            </block>
                        </view>
                    </view>
                    <view class="record-text">
                        <view>购币奖励规则：</view>
                        <view class="text-item">购币为{{ myActivityList[0].startC }}-{{myActivityList[0].endC}}以内，每购买10枚币奖励1台一级合约</view>
                        <view class="text-item">购币{{ myActivityList[1].startC }}-{{myActivityList[1].endC}}币每100币奖励一台二级合约，满{{myActivityList[1].endC}}币奖励500矿池；</view>
                        <view class="text-item">购币{{ myActivityList[2].startC }}-{{myActivityList[2].endC}}币，每100币奖励一台二级合约，满{{myActivityList[2].endC}}币奖励一台三级合约和1500矿池</view>
                        <view class="text-item">购币{{ myActivityList[3].startC }}-{{myActivityList[3].endC}}，每100币奖励一台二级合约，满{{myActivityList[3].endC}}币奖励3台三级合约和3000矿池</view>
                        <view
                            class="text-item"
                        >注意：之前累计购币数不清零，此次活动奖励为依次领取，领取后不清零，推荐人合约奖励和下级购币奖励一致，被动升级矿池不增加</view>
                    </view>
                </view>
    </view>
</template>

<script>
import { mapActions } from "vuex";
export default {
    components: {},
    data() {
        return {
            aprice: 0,
            myActivityList: [
                {
                    rprice: 0,
                    level: 1,
                    name: "购买奖励一",
					startC: 1,
					endC: 200,
					price: 10,
                    nums: 25
                },
                {
                    rprice: 0,
                    level: 2,
                    name: "购买奖励二",
					startC: 201,
					endC: 600,
					price: 201,
                    nums: 60
                },
                {
                    rprice: 0,
                    level: 3,
                    name: "购买奖励三",
					startC: 601,
					endC: 1500,
					price: 601,
                    nums: 240
                },
                {
                    rprice: 0,
                    level: 4,
                    name: "购买奖励四",
					startC: 1501,
					endC: 3000,
					price: 1501,
                    nums: 500
                }
            ],
        };
    },
    onShow() {
        this.getActivity2Count();
    },
    methods: {
        ...mapActions(["steActivityDetails"]),
		getacttwobefore () {
			this.$http.getacttwobefore().then(res => {
                uni.hideLoading();
                const data = res.data;
                if (data.success) {
					if (data.data) {
						this.myActivityList.forEach(e => {
							e.startC += data.data
							e.endC += data.data
						})
					}
					this.getActivity2Count();
                    return;
                }
                uni.showToast({
                    title: data.errMsg,
                    icon: "none"
                });
            });
		},
        getActivity2Count: function() {
            uni.showLoading({
                title: ""
            });
            this.$http.getActivityList().then(res => {
                uni.hideLoading();
                const data = res.data;
                if (data.success) {
                    this.aprice = Number(data.data);
                    return;
                }
                uni.showToast({
                    title: data.errMsg,
                    icon: "none"
                });
            });
        },
		onReceiveAward (item) {
			uni.showLoading({
                title: ""
            });
            this.$http.handleActiviytwo().then(res => {
                uni.hideLoading();
                const data = res.data;
				data.data = data.data || 0
                if (data.success) {
					uni.showToast({
						title: '领取成功',
						duration: 2000
					})
                    return;
                }
                uni.showToast({
                    title: data.errMsg,
                    icon: "none"
                });
            });
        
		},
        onDetails(item) {
            item.aprice = this.aprice;
            this.steActivityDetails(item);
            uni.navigateTo({
                url: "/pages/user/activity/details"
            });
        }
    }
};
</script>

<style scoped lang="scss">
@import "../../../common/tabs.scss";
.tbl-item {
    .item.color6 {
        color: #1989fa;
    }
}
.record {
    min-height: calc(100vh - 40px);
    background-color: #fff;
    &-title {
        position: absolute;
        z-index: 1;
        top: 5px;
        right: 0;
        left: 0;
        display: flex;
        justify-content: space-around;
        align-items: center;
        text-align: center;
        background-color: #fff;
        &-item {
            flex: 1;
            padding: 20upx 0;
            color: #1e1e1e;
            min-width: 50upx;
            &.one {
                min-width: 180upx;
                flex: none;
            }
        }
    }
    &-text {
        padding: 40upx 30upx;
        color: #9b9b9b;
    }
}
.text-item {
    text-indent: 2em;
}
</style>
